home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 1999 #2
/
Amiga Plus CD - 1999 - No. 2.iso
/
Magazin
/
WhatsRelated
/
WhatsRelated.awebrx
< prev
next >
Wrap
Text File
|
1998-10-27
|
2KB
|
104 lines
/* What's Related á la Netscape Communicator 4.06/4.5 */
/*
Q&D AWeb script by Martin Blom, 1998-10-28.
Public Domain. No support, no documentation, no updates.
*/
name = "What's Related"
nsurl1 = "http://www-rl4.netscape.com"
nsurl2 = "http://cgi.netscape.com/cgi-bin/rlcgi.cgi"
ports = SHOW('P')
PARSE VAR ports dummy 'AWEB.' portnr . /* note the trailing period! */
ADDRESS VALUE 'AWEB.' || portnr
OPTIONS RESULTS
GET ACTIVEPORT
ADDRESS VALUE RESULT
GET URL VAR url
/* Find the last "http://" and remove it and everything before it */
lastpos = LASTPOS( "http://", url )
url = RIGHT( url, LENGTH( url ) - lastpos + 1 )
fullurl = url
IF LEFT( url, 7 ) ~= "http://" THEN DO
REQUEST 'TITLE "'name'" BODY "'name' only works on HTTP documents." GADGETS "OK"'
EXIT
END
/* Cut the "http://" */
url = RIGHT( url, LENGTH( url ) - 7 )
/* Cut everything behind "?", "#" or "@" */
lastpos = INDEX( url, "?" )
lastpos2 = INDEX( url, "#" )
lastpos3 = INDEX( url, "@" )
IF lastpos = 0 THEN lastpos = lastpos2
IF lastpos = 0 THEN lastpos = lastpos3
IF lastpos2 ~= 0 THEN lastpos = MIN( lastpos, lastpos2 )
IF lastpos3 ~= 0 THEN lastpos = MIN( lastpos, lastpos3 )
IF lastpos ~= 0 THEN url = LEFT( url, lastpos )
/* Now ask the server */
LOAD 'URL "'nsurl1 || '/wtgn?' || url || '" RELOAD SAVEAS "T:WhatsRelated.tmp" NOICON'
WAIT 'URL "'nsurl1 || '/wtgn?' || url || '"'
/* Semi-parse the XML response */
IF OPEN( rdf, "T:WhatsRelated.tmp", "READ" ) THEN DO
body = ""
gadgets = ""
urls. = ""
counter = 1
DO WHILE EOF( rdf ) = 0
line = READLN( rdf )
IF LEFT( line, 7 ) = "<child " THEN DO
CALL HandleChild( line )
END
END
CALL CLOSE( rdf )
ADDRESS COMMAND "Delete T:WhatsRelated.tmp QUIET"
gadgets = gadgets || "D|X"
urls.counter = nsurl2 || "?URL=" || fullurl
result = 0
REQUEST 'TITLE "'name'" BODY "'body'" GADGETS "'gadgets'"'
IF result ~= 0 THEN OPEN 'URL "'urls.result || '"'
END
EXIT
HandleChild: PROCEDURE EXPOSE body gadgets urls. counter
PARSE ARG line
PARSE VAR line . 'href="' href '"' .
PARSE VAR line . 'name="' name '"' .
PARSE VAR line . 'instanceOf="' instanceOf '"' .
IF instanceOf ~= "" THEN body = body || "*N"
ELSE IF href ~= "" & name ~= "" THEN DO
body = body || counter || ": " || name || "*N"
gadgets = gadgets || counter || "|"
urls.counter = href
counter = counter + 1
END
RETURN